"""__author__ = fzzy"""

from rest_framework import serializers

from orders.models import OrderPModel, OrderDetailModel, OrderFoodModel, OrderCommentModel, PayModel
from shops.serializers import ShopsSerializer


class PaySerializer(serializers.ModelSerializer):

    class Meta:
        model = PayModel
        fields = '__all__'


class OrderPSerializer(serializers.ModelSerializer):
    shop = ShopsSerializer()

    class Meta:
        model = OrderPModel
        fields = '__all__'

    def to_representation(self, instance):
        data = super().to_representation(instance)
        pay = PayModel.objects.filter(order_id=instance.order_id).first()
        data['pay_status'] = pay.status
        return data


class OrderDetailSerializer(serializers.ModelSerializer):

    class Meta:
        model = OrderDetailModel
        fields = '__all__'


class OrderFoodSerializer(serializers.ModelSerializer):

    class Meta:
        model = OrderFoodModel
        fields = '__all__'


class OrderCommentSerializer(serializers.ModelSerializer):

    class Meta:
        model = OrderCommentModel
        fields = '__all__'




